﻿@model DoAnForum.Models.ShowTopicModel
@{
    ViewBag.Title = "ShowComment";
}

@{
    var logo = "../.." + Model.User.UserPhoto;
    var currUser = Membership.GetUser() != null ? Membership.GetUser().UserName.ToUpper() : null;
    var ownerUser = Model.Auser.UserName.ToUpper();
    var userThanked = ViewBag.userThanked;
}
<div class="cm-content" id="comment-@Model.Comment.CommentId">
    <div class="span1 cm-left">
        <div id="thank-@Model.Comment.CommentId">
            <div class="cm-votes">@Model.NoThank<span>Votes</span></div>
            @if(Model.Comment.FlaggedAsSpam!=true && Request.IsAuthenticated && !(ownerUser.Equals(currUser))&& !userThanked.Contains(currUser))
            {
                @Ajax.ActionLink("Thank", "ThankUp", "Share", new { commentId = Model.Comment.CommentId, crrName = currUser }, 
                                       new AjaxOptions
                                           {
                                               HttpMethod = "POST",
                                               UpdateTargetId = "thank-" + Model.Comment.CommentId
                                           }) 
            }
        </div>
        @if ((User.IsInRole("Admin") || User.IsInRole("Mod")) && !Model.Comment.IsStartTopic && Model.Comment.FlaggedAsSpam != true)
        {
            @Ajax.ActionLink("Delete", "DeleteComment", "Comment", new { id = Model.Comment.CommentId }, 
                                   new AjaxOptions
                                       {
                                           HttpMethod = "POST", 
                                           UpdateTargetId = "comment-" + Model.Comment.CommentId,
                                           Confirm = "Are you sure?"
                                       })
        }
        @if (Model.Comment.FlaggedAsSpam != true && Request.IsAuthenticated && (ownerUser.Equals(currUser) || User.IsInRole("Admin") || User.IsInRole("Mod")))
        {
            @Html.ActionLink("Edit", "EditComment","Comment", new { id= Model.Comment.CommentId}, null) 
        }
    </div>
    <div class="cm-center">
        <div class="cm-center-top">
            Sửa lần cuối bởi @Model.LastEditUser.UserName  vào @Model.Comment.CommentLastEditDate
        </div>
        <div class="cm-center-bottom">
            @Html.Raw(Model.Comment.CommentBody)
        </div>
        @if (Model.Comment.IsStartTopic)
        {
            Html.RenderAction("TagBarPartial", "Share", new { id = Model.Comment.TopicId });
        }
    </div>
    <div class="cm-right">
        <div class="cm-right-top">
            <p class="cm-creator">Đăng bởi</p>
            <p class="cm-creator-avatar">
                <a href=@Url.Action("ShowProfile", "Account", new { userName = Model.Auser.UserName })><img src=@logo alt=@Model.Auser.UserName title=@Model.Auser.UserName></a>
            </p>
            <p class="cm-Nopost">@Model.NoPost bài</p>
        </div>
        <div class="cm-right-bottom">
            
        </div>
    </div>
</div>